def BiSearch(arr, key):
    count = 0
    low = 0
    high = len(arr) - 1
    while low <= high:
        count += 1
        mid = (low + high) // 2
        if arr[mid] < key:
            low = mid + 1
        elif arr[mid] > key:
            high = mid - 1
        else:
            print(f"查找次数为: {count}")
            return mid
    print(f"查找次数为: {count}")
    return -1

# 获取用户输入的数组元素，以空格分隔
input_str = input("请输入有序数组元素，以空格分隔: ")
arr = [int(x) for x in input_str.split()]

# 获取用户输入的目标值
key = int(input("请输入待查找元素: "))

result = BiSearch(arr, key)
if result != -1:
    print(f"所需要查找值位置: {result}")
else:
    print("无查找值!")